import React from 'react';
import {useNavigate} from "react-router-dom";
const userList = ["zhangsan","lisi","wangwu"];
function Login(props) {
    const navigate = useNavigate();
    const login = function(e){
        if(e.keyCode === 13){
            if(userList.includes(e.target.value))
            {
                localStorage.setItem("token",e.target.value);
                navigate(-1);// 后退，返回
            }

            else alert("账号不正确")
        }

    }
    return (
        <div>
            <h3>登陆界面</h3>
            <input onKeyUp={login} type="text"/>
        </div>
    );
}

export default Login;